int done = 0;
char *buf = xmalloc(MY_CBUF_SZ);
int result = 0;
+ int extra;
while (!done) {
if ( fd ) {
buf[len] = '\0';
badchar = buf+len-maxentlength;
badchar = strchr( badchar, '&' );
- while ( badchar ) {
+ extra = maxentlength - 1; /* for terminator */
+ while ( badchar && len < MY_CBUF_SZ-1) {
int extra = maxentlength-1; /* for terminator */
semi = strchr( badchar, ';');
while ( extra && !semi ) {